reftests: Create the surface after running the main loop
authorBenjamin Otte <otte@redhat.com>
Sat, 10 May 2014 15:20:11 +0000 (17:20 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 11 May 2014 01:23:55 +0000 (03:23 +0200)
Running the main loop may cause resizes, so creating the surface based
on the size before running it seems wrong.

testsuite/reftests/gtk-reftest.c

index 3cb8d0cb92281f2b7eae7626570a0740bab68e5b..6ba539924f81e105e13c3047cf82033026363975 100644 (file)
@@ -232,11 +232,6 @@ snapshot_widget (GtkWidget *widget, SnapshotMode mode)
 
   g_assert (gtk_widget_get_realized (widget));
 
-  surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
-                                               CAIRO_CONTENT_COLOR,
-                                               gtk_widget_get_allocated_width (widget),
-                                               gtk_widget_get_allocated_height (widget));
-
   loop = g_main_loop_new (NULL, FALSE);
   /* We wait until the widget is drawn for the first time.
    * We can not wait for a GtkWidget::draw event, because that might not
@@ -246,6 +241,11 @@ snapshot_widget (GtkWidget *widget, SnapshotMode mode)
   gdk_event_handler_set (check_for_draw, loop, NULL);
   g_main_loop_run (loop);
 
+  surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+                                               CAIRO_CONTENT_COLOR,
+                                               gtk_widget_get_allocated_width (widget),
+                                               gtk_widget_get_allocated_height (widget));
+
   cr = cairo_create (surface);
 
   switch (mode)